<template>
  <div>
    <video id="myVideo" ref="videoPlayer" class="video-js vjs-default-skin" controls preload="auto"></video>
  </div>
</template>

<script>
  import videojs from 'video.js';
  import 'video.js/dist/video-js.css';
  import projectConfig from '@/core/config';
  export default {
    data() {
      return {
        player: null
      };
    },
    mounted() {
      this.player = videojs(this.$refs.videoPlayer, {
        fluid: true,
        autoplay: 'any',
        muted: false,
        controls: false, // 隐藏控件
        controlBar: false// 隐藏控制条
      },function onPlayerReady() {
        console.log('Player is ready');
      });

      // 加载视频流
      this.player.src({
        src: projectConfig.baseUrl + 'admin/biz/video/welcome',
        type: 'video/mp4' // 视频流类型，根据实际情况修改
      });

      // 监听视频播放结束事件
      this.player.on('ended', () => {
        console.log('欢迎视频播放结束');
        this.$router.replace({name: 'courseLogin', query: {}});
      });
    },
    beforeDestroy() {
      if (this.player) {
        this.player.dispose();
      }
    }
  };
</script>

<style scoped>
</style>
